package com.jzo2o.customer.controller.operation;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.WorkerCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationResDTO;
import com.jzo2o.customer.service.IWorkerCertificationAuditService;
import com.jzo2o.customer.service.IWorkerCertificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author itcast
 */
@RestController("operationWorkerCertificationController")
@RequestMapping("/operation/worker-certification-audit")
@Api(tags = "运营端 - 服务人员认证信息相关接口")
public class WorkerCertificationController {

    @Resource
    private IWorkerCertificationService workerCertificationService;
    @Autowired
    private IWorkerCertificationAuditService workerCertificationAuditService;

    @GetMapping("/{id}")
    @ApiOperation("根据服务人员id查询认证信息")
    public WorkerCertificationResDTO queryById(@PathVariable("id") Long id) {
        return BeanUtil.toBean(workerCertificationService.getById(id), WorkerCertificationResDTO.class);
    }

    @GetMapping("/page")
    @ApiOperation("分页查询服务人员认证信息")
    public PageResult pageQuery(WorkerCertificationAuditPageQueryReqDTO dto) {
        return workerCertificationAuditService.pageQuery(dto);
    }

    @PutMapping("/audit/{id}")
    @ApiOperation("审核服务人员的认证信息")
    public void audit(@PathVariable Long id, @RequestParam(value = "certificationStatus") Integer certificationStatus, @RequestParam("rejectReason") String rejectReason) {
        workerCertificationAuditService.audit(id, certificationStatus, rejectReason);
    }
}
